package org.zjx.resolution;

import org.zjx.common.entity.Rect;
import org.zjx.resource.IBaseConfig;
import org.zjx.resource.ResourceManager;

import java.util.Map;


public interface IScreenResolution {
    // 访问器方法（无具体实现）
    String getGameResName();
    Rect getOriginBounds();
    String getRefImage();
    Rect getRefImageArea();
    Map<String, Object> getProperties();
    Map<String, ResolutionAttributes> getAttributesArea();
    Map<String, ResolutionButton> getButtonsArea();

    // 修改器方法（无具体实现）
    void setGameResName(String name);
    void setOriginBounds(Rect bounds);
    void setRefImage(String image);
    void setRefImageArea(Rect area);


    void setProperties(Map<String, Object> properties);
    void setAttributesArea(Map<String, ResolutionAttributes> attributesArea);
    void setButtonsArea(Map<String, ResolutionButton> buttonsArea);

    // 默认方法实现
    default void setProperty(String key, String value) {
        getProperties().put(key, value);
    }

    default Object getProperty(String key) {
        return getProperties().get(key);
    }

    default void setAttribute(String key, ResolutionAttributes attribute) {
        getAttributesArea().put(key, attribute);
    }

    default ResolutionAttributes getAttribute(String key) {
        return getAttributesArea().get(key);
    }

    default void setButton(String key, ResolutionButton button) {
        getButtonsArea().put(key, button);
    }

    default ResolutionButton getButton(String key) {
        return getButtonsArea().get(key);
    }

    boolean loadResolution();

    default IScreenResolution loadResolution(IBaseConfig.GameTheme gameTheme) {
        return ResolutionManager.getInstance().loadResolution(
                ResourceManager.CONFIG.resolution(),
                gameTheme,
                this.getClass().getSimpleName());
    }

    default void saveResolution(IBaseConfig.GameTheme gameTheme) {
        ResolutionManager.getInstance().saveResolution(
                ResourceManager.CONFIG.resolution(),
                gameTheme,
                this.getClass().getSimpleName(),
                this
        );
    }
}